//
//  ZYCStuAttendanceStatistCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/27.
//

#import "ZYCStuAttendanceStatistCell.h"
#import "ZYCAttendanceStatusGroupView.h"
#import "ZYCAttendanceStatisticsModel.h"
@interface ZYCStuAttendanceStatistCell ()

@property (nonatomic, strong) UILabel *gradeLabel;
@property (nonatomic, strong) UILabel *line;
//正常
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *noramlGroupView;
//迟到
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *lateGroupView;
//请假
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *leaveGroupView;
//未到
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *absentlGroupView;


@end


@implementation ZYCStuAttendanceStatistCell

- (void)setModel:(ZYCAttendanceStatisticsModel *)model{
    _model = model;
    _gradeLabel.text = model.gradeName;
    _noramlGroupView.title = @"正常";
    _noramlGroupView.count = model.countZC;
    
    _lateGroupView.title = @"迟到";
    _lateGroupView.count = model.countCD;
    
    _leaveGroupView.title = @"请假";
    _leaveGroupView.count = model.countQJ;
    
    _absentlGroupView.title = @"未到";
    _absentlGroupView.count = model.countWD;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.gradeLabel];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.noramlGroupView];
        [self.contentView addSubview:self.lateGroupView];
        [self.contentView addSubview:self.leaveGroupView];
        [self.contentView addSubview:self.absentlGroupView];
        
        [self.gradeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(19.0f);
            make.top.equalTo(self.contentView).offset(20.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(20.0f);
            make.right.equalTo(self.contentView).offset(-20.0f);
            make.top.equalTo(self.gradeLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1);
        }];
        
        
        CGFloat margin  = (kScreenWidth  - 50 * 4) / 5;
        
        [self.noramlGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.contentView).offset(margin);
            make.top.equalTo(self.line.mas_bottom).offset(20.0f);
        }];
        
        [self.lateGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.noramlGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
        
        [self.leaveGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.lateGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
        [self.absentlGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.leaveGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
        
        
        
    
        

    }
    return self;
}

- (ZYCAttendanceStatusGroupView *)noramlGroupView {
    if (!_noramlGroupView) {
        _noramlGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _noramlGroupView.color = HEX_RGB(@"#39A85B");
    }
    return _noramlGroupView;
}

- (ZYCAttendanceStatusGroupView *)lateGroupView {
    if (!_lateGroupView) {
        _lateGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _lateGroupView.color = HEX_RGB(@"#E93C06");
    }
    return _lateGroupView;
}

- (ZYCAttendanceStatusGroupView *)leaveGroupView {
    if (!_leaveGroupView) {
        _leaveGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _leaveGroupView.color = HEX_RGB(@"#FDA252");
    }
    return _leaveGroupView;
}


- (ZYCAttendanceStatusGroupView *)absentlGroupView {
    if (!_absentlGroupView) {
        _absentlGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _absentlGroupView.color = HEX_RGB(@"#B9B9B9");
    }
    return _absentlGroupView;
}

- (UILabel *)gradeLabel {
    if (!_gradeLabel) {
        _gradeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 17.0f) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
    }
    return _gradeLabel;
}

- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _line;
}
@end
